<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2021/7/30
  Time: 18:59
  To change this template use File | Settings | File Templates.
--%>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>商品管理界面</title>
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://www.layuicdn.com/layui-v2.6.8/css/layui.css"  media="all">
    <style>

        #nav {
            margin: 50px auto;
            height: 40px;
            background-color:    #6fb9c8;
        }
        #nav ul {
            list-style: none;
            margin-left: 50px;
        }
        #nav li {
            display: inline;
        }
        #nav a {
            line-height: 40px;
            color: #fff;
            text-decoration: none;
            padding: 20px 20px;
        }
        #nav a:hover {
            background-color:  #ffac46;
        }

    </style>
</head>

<body >
<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="page-header">
                <h1>
                    <small>DEEP.SPACE----商品管理</small>
                    <a href="${pageContext.request.contextPath}/Admin/Menu" class="btn btn-danger" style="margin-left: 55%">退出</a>
                </h1>
            </div>
        </div>
    </div>
    <div >
        <div class="row" >
        <div class="col-md-4 column" >
            <span class="glyphicon glyphicon-folder-open"></span>
            <a class="btn btn-primary"  href="${pageContext.request.contextPath}/Product/toAddProduct">新增</a>
        </div>
        </div>
    <div class="row" >
        <div class="col-md-4 column">
            <form action="${pageContext.request.contextPath}/Product/query" method="post">
                <span class="glyphicon glyphicon-search"></span>
                <input type="text" placeholder="请输入商品编号" name="pid" >
                <button type="submit" class="btn btn-default" style="color: brown" >搜索</button>
            </form>
        </div>
    </div>
    </div>

    </div>
</div>
<div class="row clearfix">
        <div class="col-md-12 column">

            <table class="table table-hover table-striped">
                <thead>
                <tr>
                    <th>商品编号</th>
                    <th>商品名字</th>
                    <th>商品数量</th>
                    <th>商品销售量</th>
                    <th>商品颜色</th>
                    <th>商品图片</th>
                    <th>商品价格</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="product" items="${requestScope.get('list')}">
                    <tr>
                        <td>${product.getPid()}</td>
                        <td>${product.getPname()}</td>
                        <td>${product.getPnum()}</td>
                        <td>${product.getPsold()}</td>
                        <td>${product.getPcolor()}</td>
                        <td><img src=/imgs/${product.getPimg()} width="100" height="100"></td>
                        <td>${product.getPmoney()}</td>
                        <td>
                            <a href="${pageContext.request.contextPath}/Product/toUpdateProduct?id=${product.getPid()}" style="color: crimson">更改</a> |
                            <a href="${pageContext.request.contextPath}/Product/del/${product.getPid()}" style="color: crimson">删除</a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
    </div>

<!-- 显示分页信息 -->
<div class="clear"></div>
<div class="pagin">
    <div class="message">共<i class="blue">${pageInfo.total }</i>条记录，当前显示第&nbsp;<i class="blue">${pageInfo.pageNum }&nbsp;</i>页
        总<i class="
 blue">${pageInfo.pages }</i>页
    </div>
    <ul class="paginList" id="nav">
        <li class="paginItem"><a href="${pageContext.request.contextPath}/Product/allProduct?currentPage=1">首页</a></li>
        <c:if test="${pageInfo.hasPreviousPage }">
            <li  class="paginItem"><a href="${pageContext.request.contextPath}/Product/allProduct?currentPage=${pageInfo.pageNum-1}"
            > <span>&laquo;</span>
            </a></li>
        </c:if>
        <c:forEach items="${pageInfo.navigatepageNums }" var="page_Num">
            <c:if test="${page_Num == pageInfo.pageNum }">
                <li class="paginItem"><a href="#">${page_Num }</a></li>
            </c:if>
            <c:if test="${page_Num != pageInfo.pageNum }">
                <li class="paginItem"><a href="${pageContext.request.contextPath}/Product/allProduct?currentPage=${page_Num }">${page_Num }</a></li>
            </c:if>

        </c:forEach>
        <c:if test="${pageInfo.hasNextPage }">
            <li class="paginItem"><a href="${pageContext.request.contextPath}/Product/allProduct?currentPage=${pageInfo.pageNum+1 }"> <span>&raquo;</span></a></li>
        </c:if>
        <li class="paginItem"><a href="${pageContext.request.contextPath}/Product/allProduct?currentPage=${pageInfo.pages}">末页</a></li>
    </ul>
</div>

</div>
</body>
</html>